"""
处理引擎
    处理流程：
        DataProcess -->  数据处理
            |
        ComponentManager  -->  生成管理
            |
        ManageEvent   -->  事件管理
"""
import time

import settings
import os
from read_func import DataProcess
from midd_creat_component import ComponentManager
from midd_event_manage import ManageEvent

class ProcessingEngine:
    def __init__(self,file_path):
        self.file_path = file_path                            # 运行文件地址
        self.events = None

        data = self.data_process()                            # 数据处理
        self.events = self.component_manager(data)            # 组件管理生成事件
        print(f'处理后的数据{data}')
        self.start()                                          # 开始执行

    def data_process(self):
        """数据处理"""
        print('开始数据处理')
        data_process = DataProcess(self.file_path)
        return data_process()

    def component_manager(self,data):
        """组件管理"""
        print('开始组件管理')
        component_manager = ComponentManager(data)
        return component_manager()

    def start(self):
        """开始执行"""
        print('等待3s开始执行')
        time.sleep(3)
        manage_event = ManageEvent(self.events)
        manage_event.start()

if __name__ == '__main__':
    # file_path = os.path.join(settings.USER_PATH,'测试数据2.json')
    file_path = os.path.join(settings.USER_PATH,'拖拽测试.json')
    pe = ProcessingEngine(file_path)
    print(pe.events)